package com.xquant.pricing.rocketmq;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;

import com.xquant.pricing.utils.DateUtils;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Service;

import java.util.Map;


/**
 * @author zes
 * @createDateTime 2022/5/12 1:33 上午
 */
@Service
@RefreshScope
@RocketMQMessageListener(topic = "${rocketmq.trade-topic}", selectorExpression = "*", consumerGroup = "${rocketmq.consumer.group}")
public class RocketMqTradeConsumer implements RocketMQListener<JSONObject> {
    protected static final Logger logger = LoggerFactory.getLogger(RocketMqTradeConsumer.class);

    @Override
    public void onMessage(JSONObject jsonObject) {
        logger.info(jsonObject.getStr("iCode") + " 到达队列监听器（rocketmq）");
        String current = DateUtils.getCurr_YYYY_MM_DD();
        logger.info("到达队列监听器");
        Map param = (Map) JSONUtil.parse(jsonObject);
        try {
            String terminationDate = (String) param.get("terminationDate");
            String issueDate = (String) param.get("issueDate");

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

